package logic

import (
	"context"
	"house_srv/models"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollentAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollentAddLogic {
	return &CollentAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 看房收藏
func (l *CollentAddLogic) CollentAdd(in *house.CollentAddRequest) (*house.CollentAddResponse, error) {
	// todo: add your logic here and delete this line
	collects := models.Collect{
		UserId:  int(in.UserId),
		HouseId: int(in.HouseId),
		Address: in.Address,
	}
	models.DB.Debug().Create(&collects)
	return &house.CollentAddResponse{
		Id: int64(collects.ID),
	}, nil
}
